package com.example.springioc.controller;

import com.example.springioc.dao.Student;
import com.example.springioc.dao.UserInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/properties")
public class PropertiesController {

    // 使用@Value从properties配置文件中读取内容
    @Value(value = "${mykey}")
    private String mykey;


    @RequestMapping("/getMykey")
    public String getMykey() {
        return "myKey: "+ mykey;
    }



    // 使用@Value从yml配置文件中读取内容
    @Value(value = "${mykey2}")
    private String mykey2;

    @RequestMapping("/getMykey2")
    public String getMykey2() {
        return "myKey2: "+ mykey2;
    }


    @Autowired
    private Student student;

    @RequestMapping("/getStudent")
    public Student getStudent() {
        System.out.println(student);
        return student;
    }

}
